home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-07-06 | 3.3 KB | 132 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CSearchWindow.h
- // ---------------------
- // ©1996 Eric Gundrum, All rights reserved.
- // The contents of this file may be freely altered and freely distributed
- // in any form, provided this copyright statement is retained unaltered.
- // Add your own changes below.
- // ---------------------
- //
- // Coordinate activities of the Search Window.
- //
-
- #pragma once
-
- // PowerPlant Headers
- #include <LListener.h>
- #include <LWindow.h>
-
- // Library Headers
- #include "DMultiStringLocator.h"
-
-
- #pragma mark --- CSearchString declarations ---
- // ===========================================================================
- // Container for a search string and its report function.
-
- class CSearchString : public DSearchString
- {
- public:
- CSearchString();
- virtual Boolean ReportFound( long /*inPosition*/ );
- static Int32 SetBufferOffset( Int32 inOffset );
- Int32 GetFoundCount() { return mFoundCount; }
-
- private:
- Int32 mFoundCount;
- long mLastFoundPosition; // location of end of last found
- static long mBufferOffset; // file position of start of buffer
- };
-
-
- // ---------------------------------------------------------------------------
- //
- inline
- CSearchString::CSearchString()
- {
- mFoundCount = 0;
- mLastFoundPosition = 0;
- }
-
-
- // ---------------------------------------------------------------------------
- //
- inline Boolean
- CSearchString::ReportFound( long inPosition )
- {
- inPosition += mBufferOffset; // normalize found position
- if ( inPosition > mLastFoundPosition ) // new found string
- {
- mLastFoundPosition = inPosition;
- mFoundCount += 1;
- }
- return true;
- }
-
-
- // ---------------------------------------------------------------------------
- //
- inline Int32
- CSearchString::SetBufferOffset( Int32 inOffset )
- {
- return mBufferOffset = inOffset;
- }
-
-
- #pragma mark --- CSearchWindow declarations ---
- // ===========================================================================
- // Search Window coordinator.
-
- class CSearchWindow : public LListener
- , public LCommander
- {
- public:
- virtual ~CSearchWindow();
- CSearchWindow();
-
- void ShowSearchWindow();
- void DoSearch();
- void SearchFile( LFileStream &inTarget );
-
- Boolean WindowExists() { return nil != mSearchWindowP; }
- virtual void ListenToMessage(
- MessageT inMessage,
- void* ioParam
- );
- virtual Boolean AllowSubRemoval( LCommander *inSubP );
-
- private:
- // stop defaults
- CSearchWindow( const CSearchWindow &inOriginal );
-
- void InsertSearchItem
- ( Int32 inPos, LEditField &inEditField );
- void EmptySearchList();
-
- LWindow *mSearchWindowP; // search queary window
- LList mSearchList; // pointers to search strings
- public:
- // Window identifiers
- enum {
- msg_FilterExecute = 'FndB'
- , msg_FilterCancel = 'CanB'
- };
-
- enum PaneIDT {
- button_FilterExecute = 'FndB'
- , button_FilterCancel = 'CanB'
- , editField_Target1 = 'St1E'
- , editField_Target2 = 'St2E'
- , editField_Target3 = 'St3E'
- , caption_Result1 = 'Sr1C'
- , caption_Result2 = 'Sr2C'
- , caption_Result3 = 'Sr3C'
- , caption_Duration = 'SrDC'
- };
- };
-
- // Find Window resource identifiers
- const ResIDT window_Search = 1100;
-
- // ===========================================================================
- // EOF